package com.demo.webmagic.pipeline;

import com.demo.common.constant.ConstantHttp;
import com.demo.common.model.Proxyip;
import com.demo.webmagic.dto.DtoResult;

import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

public class PipelineValiProxyIp implements Pipeline {

	@Override
	public void process(ResultItems resultItems, Task task) {
		DtoResult dtoResult = resultItems.get("result");
		if(dtoResult.getCode() == ConstantHttp.code_success) {
			Proxyip proxyip = (Proxyip) dtoResult.getObj();
			proxyip.setIsVali(1);
			proxyip.update();
		} else {
			Proxyip proxyip = (Proxyip) dtoResult.getObj();
			proxyip.delete();
		} 
	}

}
